from threading import Thread
import time

egg = 0
num = 6


class cook(Thread):
    username = ""  # 厨师
    egg1 = 0
    cun = 0

    def run(self) -> None:
        global egg
        global num
        while True:
            if egg < 500:
                egg = egg + 1
                self.egg1 = self.egg1 + 1
            else:
                if num != 0:
                    print("篮子已经满了，请等待")
                    for i in range(3):
                        print(".")
                        time.sleep(1)
                else:
                    self.cun = self.egg1 * 1.5
                    # print(self.username, "做了", self.egg1, "个蛋挞。获得工资为:", self.cun)
                    break
        print("______________________________________________________________________")
        print(q1.username, "做了", q1.egg1, "个蛋挞工资为:", q1.cun)
        print(q2.username, "做了", q2.egg1, "个蛋挞工资为:", q2.cun)
        print(q3.username, "做了", q3.egg1, "个蛋挞工资为:", q3.cun)
        print(b1.username1, "购买了", b1.quantity, "个蛋挞")
        print(b2.username1, "购买了", b2.quantity, "个蛋挞")
        print(b3.username1, "购买了", b3.quantity, "个蛋挞")
        print(b4.username1, "购买了", b4.quantity, "个蛋挞")
        print(b5.username1, "购买了", b5.quantity, "个蛋挞")
        print(b5.username1, "购买了", b6.quantity, "个蛋挞")
        sum1 = b1.quantity + b2.quantity + b3.quantity + b4.quantity + b5.quantity + b6.quantity
        print("赚到的总钱数:", sum1 * 3)


class client(Thread):
    username1 = ""  # 顾客
    quantity = 0  # 蛋挞数量
    money = 5000

    def run(self) -> None:
        global egg
        global num
        while True:
            if self.money > 3 and egg > 0:
                egg = egg - 1
                self.money = self.money - 3
                self.quantity = self.quantity + 1
            elif self.money >= 3 and egg == 0:
                print("蛋挞售卖完了，请等待")
                for i in range(3):
                    print("*****")
                    time.sleep(1)
            else:
                num = num - 1
                # print(self.username1, "购买的蛋挞数量:", self.quantity)
                break


q1 = cook()
q2 = cook()
q3 = cook()
q1.username = "厨师1"
q2.username = "厨师2"
q3.username = "厨师3"
b1 = client()
b2 = client()
b3 = client()
b4 = client()
b5 = client()
b6 = client()
b1.username1 = "小明"
b2.username1 = "小明1"
b3.username1 = "小明2"
b4.username1 = "小明3"
b5.username1 = "小明4"
b6.username1 = "小明5"
q1.start()
q2.start()
q3.start()
b1.start()
b2.start()
b3.start()
b4.start()
b5.start()
b6.start()
